package com.contory.ssn_lgnd.app;

import com.contory.ssn_lgnd.app.comp.ViewObject;
import com.contory.ssn_lgnd.framework.math.Vector2;

public class KeyFrameAnimation {
	public static boolean scaleUpWidth(ViewObject obj, float deltaTime, float incRate, float limit){
		obj.w += incRate * deltaTime;
		if(obj.w > limit){
			obj.w = limit;
			return true;
		}
		return false;
	}
	
	public static boolean scaleUpHeight(ViewObject obj, float deltaTime, float incRate, float limit){
		obj.h += incRate * deltaTime;
		if(obj.h > limit){
			obj.h = limit;
			return true;
		}
		return false;
	}
	
	public static boolean scaleUp(ViewObject obj, float deltaTime, float incRate, float limit){
		if(scaleUpHeight(obj, deltaTime, incRate, limit) & scaleUpWidth(obj, deltaTime, incRate, limit))
			return true;
		else 
			return false;
	}
	
	public static boolean translateY(ViewObject obj, float deltaTime, float velY, float endY){
		obj.y += velY * deltaTime;
		boolean endMovY = false;
		if(velY < 0){
			if(obj.y < endY){
				obj.y = endY;
				endMovY = true;
			}
		}
		else if(velY >= 0){
			if(obj.y > endY){
				obj.y = endY;
				endMovY = true;
			}
		}
		return endMovY;
	}
	
	public static boolean translateX(ViewObject obj, float deltaTime, float velX, float endX){
		obj.x += velX * deltaTime;
		boolean endMovX = false;
		if(velX < 0){
			if(obj.x < endX){
				obj.x = endX;
				endMovX = true;
			}
		}
		else if(velX >= 0){
			if(obj.x > endX){
				obj.x = endX;
				endMovX = true;
			}
		}
		return endMovX;
	}
	
	public static boolean translate(ViewObject obj, float deltaTime, Vector2 vel, Vector2 end){
		if(translateX(obj, deltaTime, vel.x, end.x) & translateY(obj, deltaTime, vel.y, end.y))
			return true;
		else 
			return false;
	}
}
